package ch.nostromo.tiffanys.engines.tiffanys.ai;

public class TiffanysAiTools {
  public static int[] COMMON_BOARD_VALUES = null;

  public static int[] PAWN_WHITE_VALUES = null;

  public static int[] PAWN_BLACK_VALUES = null;

  public static int[] KNIGHT_WHITE_VALUES = null;

  public static int[] KNIGHT_BLACK_VALUES = null;

  public static int[] BISHOP_WHITE_VALUES = null;

  public static int[] BISHOP_BLACK_VALUES = null;

  public static int[] ROOK_WHITE_VALUES = null;

  public static int[] ROOK_BLACK_VALUES = null;
  

  public static int[] QUEEN_WHITE_VALUES = null;

  public static int[] QUEEN_BLACK_VALUES = null;
  

  public static int[] KING_WHITE_VALUES = null;

  public static int[] KING_BLACK_VALUES = null;
  
  
  private static boolean initialized;

  public static void initialize() {
    if (initialized) {
      return;
    }

    initPawnBoards();
    initKnightBoards();
    initBishopBoards();
    initRookBoards();
    initKingBoards();
    
  }

  public static void initPawnBoards() {

    PAWN_WHITE_VALUES = new int[120];
    PAWN_BLACK_VALUES = new int[120];

    PAWN_WHITE_VALUES[21] = -15;
    PAWN_WHITE_VALUES[22] = -5;
    PAWN_WHITE_VALUES[23] = 0;
    PAWN_WHITE_VALUES[24] = 5;
    PAWN_WHITE_VALUES[25] = 5;
    PAWN_WHITE_VALUES[26] = 0;
    PAWN_WHITE_VALUES[27] = -5;
    PAWN_WHITE_VALUES[28] = -15;

    PAWN_WHITE_VALUES[31] = -15;
    PAWN_WHITE_VALUES[32] = -5;
    PAWN_WHITE_VALUES[33] = 0;
    PAWN_WHITE_VALUES[34] = 5;
    PAWN_WHITE_VALUES[35] = 5;
    PAWN_WHITE_VALUES[36] = 0;
    PAWN_WHITE_VALUES[37] = -5;
    PAWN_WHITE_VALUES[38] = -15;

    PAWN_WHITE_VALUES[41] = -15;
    PAWN_WHITE_VALUES[42] = -5;
    PAWN_WHITE_VALUES[43] = 0;
    PAWN_WHITE_VALUES[44] = 15;
    PAWN_WHITE_VALUES[45] = 15;
    PAWN_WHITE_VALUES[46] = 0;
    PAWN_WHITE_VALUES[47] = -5;
    PAWN_WHITE_VALUES[48] = -15;

    PAWN_WHITE_VALUES[51] = -15;
    PAWN_WHITE_VALUES[52] = -5;
    PAWN_WHITE_VALUES[53] = 0;
    PAWN_WHITE_VALUES[54] = 25;
    PAWN_WHITE_VALUES[55] = 25;
    PAWN_WHITE_VALUES[56] = 0;
    PAWN_WHITE_VALUES[57] = -5;
    PAWN_WHITE_VALUES[58] = -15;

    PAWN_WHITE_VALUES[61] = -15;
    PAWN_WHITE_VALUES[62] = -5;
    PAWN_WHITE_VALUES[63] = 0;
    PAWN_WHITE_VALUES[64] = 15;
    PAWN_WHITE_VALUES[65] = 15;
    PAWN_WHITE_VALUES[66] = 0;
    PAWN_WHITE_VALUES[67] = -5;
    PAWN_WHITE_VALUES[68] = -15;

    PAWN_WHITE_VALUES[71] = -15;
    PAWN_WHITE_VALUES[72] = -5;
    PAWN_WHITE_VALUES[73] = 0;
    PAWN_WHITE_VALUES[74] = 5;
    PAWN_WHITE_VALUES[75] = 5;
    PAWN_WHITE_VALUES[76] = 0;
    PAWN_WHITE_VALUES[77] = -5;
    PAWN_WHITE_VALUES[78] = -15;

    PAWN_WHITE_VALUES[81] = -15;
    PAWN_WHITE_VALUES[82] = -5;
    PAWN_WHITE_VALUES[83] = 0;
    PAWN_WHITE_VALUES[84] = 5;
    PAWN_WHITE_VALUES[85] = 5;
    PAWN_WHITE_VALUES[86] = 0;
    PAWN_WHITE_VALUES[87] = -5;
    PAWN_WHITE_VALUES[88] = -15;

    PAWN_WHITE_VALUES[91] = -15;
    PAWN_WHITE_VALUES[92] = -5;
    PAWN_WHITE_VALUES[93] = 0;
    PAWN_WHITE_VALUES[94] = 5;
    PAWN_WHITE_VALUES[95] = 5;
    PAWN_WHITE_VALUES[96] = 0;
    PAWN_WHITE_VALUES[97] = -5;
    PAWN_WHITE_VALUES[98] = -15;

    int counter = 119;
    for (int i = 0; i < PAWN_WHITE_VALUES.length; i++) {
      PAWN_BLACK_VALUES[counter] = PAWN_WHITE_VALUES[i];
      counter --;
    }
    
  }




  public static void initKnightBoards() {

    KNIGHT_WHITE_VALUES = new int[120];
    KNIGHT_BLACK_VALUES = new int[120];

    KNIGHT_WHITE_VALUES[21] = -50;
    KNIGHT_WHITE_VALUES[22] = -40;
    KNIGHT_WHITE_VALUES[23] = -30;
    KNIGHT_WHITE_VALUES[24] = -25;
    KNIGHT_WHITE_VALUES[25] = -25;
    KNIGHT_WHITE_VALUES[26] = -30;
    KNIGHT_WHITE_VALUES[27] = -40;
    KNIGHT_WHITE_VALUES[28] = -50;

    KNIGHT_WHITE_VALUES[31] = -35;
    KNIGHT_WHITE_VALUES[32] = -25;
    KNIGHT_WHITE_VALUES[33] = -15;
    KNIGHT_WHITE_VALUES[34] = -10;
    KNIGHT_WHITE_VALUES[35] = -10;
    KNIGHT_WHITE_VALUES[36] = -15;
    KNIGHT_WHITE_VALUES[37] = -25;
    KNIGHT_WHITE_VALUES[38] = -35;

    KNIGHT_WHITE_VALUES[41] = -20;
    KNIGHT_WHITE_VALUES[42] = -10;
    KNIGHT_WHITE_VALUES[43] = 0;
    KNIGHT_WHITE_VALUES[44] = 5;
    KNIGHT_WHITE_VALUES[45] = 5;
    KNIGHT_WHITE_VALUES[46] = 0;
    KNIGHT_WHITE_VALUES[47] = -10;
    KNIGHT_WHITE_VALUES[48] = -20;

    KNIGHT_WHITE_VALUES[51] = -10;
    KNIGHT_WHITE_VALUES[52] = 0;
    KNIGHT_WHITE_VALUES[53] = 10;
    KNIGHT_WHITE_VALUES[54] = 15;
    KNIGHT_WHITE_VALUES[55] = 15;
    KNIGHT_WHITE_VALUES[56] = 10;
    KNIGHT_WHITE_VALUES[57] = 0;
    KNIGHT_WHITE_VALUES[58] = -10;

    KNIGHT_WHITE_VALUES[61] = -5;
    KNIGHT_WHITE_VALUES[62] = 5;
    KNIGHT_WHITE_VALUES[63] = 15;
    KNIGHT_WHITE_VALUES[64] = 20;
    KNIGHT_WHITE_VALUES[65] = 20;
    KNIGHT_WHITE_VALUES[66] = 15;
    KNIGHT_WHITE_VALUES[67] = 5;
    KNIGHT_WHITE_VALUES[68] = -5;

    KNIGHT_WHITE_VALUES[71] = -5;
    KNIGHT_WHITE_VALUES[72] = 5;
    KNIGHT_WHITE_VALUES[73] = 15;
    KNIGHT_WHITE_VALUES[74] = 20;
    KNIGHT_WHITE_VALUES[75] = 20;
    KNIGHT_WHITE_VALUES[76] = 15;
    KNIGHT_WHITE_VALUES[77] = 5;
    KNIGHT_WHITE_VALUES[78] = -5;

    KNIGHT_WHITE_VALUES[81] = -20;
    KNIGHT_WHITE_VALUES[82] = -10;
    KNIGHT_WHITE_VALUES[83] = 0;
    KNIGHT_WHITE_VALUES[84] = 5;
    KNIGHT_WHITE_VALUES[85] = 5;
    KNIGHT_WHITE_VALUES[86] = 0;
    KNIGHT_WHITE_VALUES[87] = -10;
    KNIGHT_WHITE_VALUES[88] = -20;

    KNIGHT_WHITE_VALUES[91] = -135;
    KNIGHT_WHITE_VALUES[92] = -25;
    KNIGHT_WHITE_VALUES[93] = -15;
    KNIGHT_WHITE_VALUES[94] = -10;
    KNIGHT_WHITE_VALUES[95] = -10;
    KNIGHT_WHITE_VALUES[96] = -15;
    KNIGHT_WHITE_VALUES[97] = -25;
    KNIGHT_WHITE_VALUES[98] = -135;

    
    int counter = 119;
    for (int i = 0; i < KNIGHT_WHITE_VALUES.length; i++) {
      KNIGHT_BLACK_VALUES[counter] = KNIGHT_WHITE_VALUES[i];
      counter --;
    }
    
  }


  public static void initBishopBoards() {

    BISHOP_WHITE_VALUES = new int[120];
    BISHOP_BLACK_VALUES = new int[120];

    BISHOP_WHITE_VALUES[21] = -20;
    BISHOP_WHITE_VALUES[22] = -15;
    BISHOP_WHITE_VALUES[23] = -15;
    BISHOP_WHITE_VALUES[24] = -13;
    BISHOP_WHITE_VALUES[25] = -13;
    BISHOP_WHITE_VALUES[26] = -15;
    BISHOP_WHITE_VALUES[27] = -15;
    BISHOP_WHITE_VALUES[28] = -20;

    BISHOP_WHITE_VALUES[31] = -5;
    BISHOP_WHITE_VALUES[32] = 0;
    BISHOP_WHITE_VALUES[33] = -5;
    BISHOP_WHITE_VALUES[34] = 0;
    BISHOP_WHITE_VALUES[35] = 0;
    BISHOP_WHITE_VALUES[36] = -5;
    BISHOP_WHITE_VALUES[37] = 0;
    BISHOP_WHITE_VALUES[38] = -5;

    BISHOP_WHITE_VALUES[41] = -6;
    BISHOP_WHITE_VALUES[42] = -2;
    BISHOP_WHITE_VALUES[43] = 4;
    BISHOP_WHITE_VALUES[44] = 2;
    BISHOP_WHITE_VALUES[45] = 2;
    BISHOP_WHITE_VALUES[46] = 4;
    BISHOP_WHITE_VALUES[47] = -2;
    BISHOP_WHITE_VALUES[48] = -6;

    BISHOP_WHITE_VALUES[51] = -4;
    BISHOP_WHITE_VALUES[52] = 0;
    BISHOP_WHITE_VALUES[53] = 2;
    BISHOP_WHITE_VALUES[54] = 10;
    BISHOP_WHITE_VALUES[55] = 10;
    BISHOP_WHITE_VALUES[56] = 2;
    BISHOP_WHITE_VALUES[57] = 0;
    BISHOP_WHITE_VALUES[58] = -4;

    BISHOP_WHITE_VALUES[61] = -4;
    BISHOP_WHITE_VALUES[62] = 0;
    BISHOP_WHITE_VALUES[63] = 2;
    BISHOP_WHITE_VALUES[64] = 10;
    BISHOP_WHITE_VALUES[65] = 10;
    BISHOP_WHITE_VALUES[66] = 2;
    BISHOP_WHITE_VALUES[67] = 0;
    BISHOP_WHITE_VALUES[68] = -4;

    BISHOP_WHITE_VALUES[71] = -6;
    BISHOP_WHITE_VALUES[72] = -2;
    BISHOP_WHITE_VALUES[73] = 4;
    BISHOP_WHITE_VALUES[74] = 2;
    BISHOP_WHITE_VALUES[75] = 2;
    BISHOP_WHITE_VALUES[76] = 4;
    BISHOP_WHITE_VALUES[77] = -2;
    BISHOP_WHITE_VALUES[78] = -6;

    BISHOP_WHITE_VALUES[81] = -5;
    BISHOP_WHITE_VALUES[82] = 0;
    BISHOP_WHITE_VALUES[83] = -2;
    BISHOP_WHITE_VALUES[84] = 0;
    BISHOP_WHITE_VALUES[85] = 0;
    BISHOP_WHITE_VALUES[86] = -2;
    BISHOP_WHITE_VALUES[87] = 0;
    BISHOP_WHITE_VALUES[88] = -5;

    BISHOP_WHITE_VALUES[91] = -8;
    BISHOP_WHITE_VALUES[92] = -8;
    BISHOP_WHITE_VALUES[93] = -6;
    BISHOP_WHITE_VALUES[94] = -4;
    BISHOP_WHITE_VALUES[95] = -4;
    BISHOP_WHITE_VALUES[96] = -6;
    BISHOP_WHITE_VALUES[97] = -8;
    BISHOP_WHITE_VALUES[98] = -8;

    
    int counter = 119;
    for (int i = 0; i < BISHOP_WHITE_VALUES.length; i++) {
      BISHOP_BLACK_VALUES[counter] = BISHOP_WHITE_VALUES[i];
      counter --;
    }
    
  }

  public static void initRookBoards() {

    ROOK_WHITE_VALUES = new int[120];
    ROOK_BLACK_VALUES = new int[120];

    ROOK_WHITE_VALUES[21] = -6;
    ROOK_WHITE_VALUES[22] = -3;
    ROOK_WHITE_VALUES[23] = 0;
    ROOK_WHITE_VALUES[24] = 3;
    ROOK_WHITE_VALUES[25] = 3;
    ROOK_WHITE_VALUES[26] = 0;
    ROOK_WHITE_VALUES[27] = -3;
    ROOK_WHITE_VALUES[28] = -6;


    ROOK_WHITE_VALUES[31] = -6;
    ROOK_WHITE_VALUES[32] = -3;
    ROOK_WHITE_VALUES[33] = 0;
    ROOK_WHITE_VALUES[34] = 3;
    ROOK_WHITE_VALUES[35] = 3;
    ROOK_WHITE_VALUES[36] = 0;
    ROOK_WHITE_VALUES[37] = -3;
    ROOK_WHITE_VALUES[38] = -6;

    ROOK_WHITE_VALUES[41] = -6;
    ROOK_WHITE_VALUES[42] = -3;
    ROOK_WHITE_VALUES[43] = 0;
    ROOK_WHITE_VALUES[44] = 3;
    ROOK_WHITE_VALUES[45] = 3;
    ROOK_WHITE_VALUES[46] = 0;
    ROOK_WHITE_VALUES[47] = -3;
    ROOK_WHITE_VALUES[48] = -6;

    ROOK_WHITE_VALUES[51] = -6;
    ROOK_WHITE_VALUES[52] = -3;
    ROOK_WHITE_VALUES[53] = 0;
    ROOK_WHITE_VALUES[54] = 3;
    ROOK_WHITE_VALUES[55] = 3;
    ROOK_WHITE_VALUES[56] = 0;
    ROOK_WHITE_VALUES[57] = -3;
    ROOK_WHITE_VALUES[58] = -6;

    ROOK_WHITE_VALUES[61] = -6;
    ROOK_WHITE_VALUES[62] = -3;
    ROOK_WHITE_VALUES[63] = 0;
    ROOK_WHITE_VALUES[64] = 3;
    ROOK_WHITE_VALUES[65] = 3;
    ROOK_WHITE_VALUES[66] = 0;
    ROOK_WHITE_VALUES[67] = -3;
    ROOK_WHITE_VALUES[68] = -6;

    ROOK_WHITE_VALUES[71] = -6;
    ROOK_WHITE_VALUES[72] = -3;
    ROOK_WHITE_VALUES[73] = 0;
    ROOK_WHITE_VALUES[74] = 3;
    ROOK_WHITE_VALUES[75] = 3;
    ROOK_WHITE_VALUES[76] = 0;
    ROOK_WHITE_VALUES[77] = -3;
    ROOK_WHITE_VALUES[78] = -6;

    ROOK_WHITE_VALUES[81] = -6;
    ROOK_WHITE_VALUES[82] = -3;
    ROOK_WHITE_VALUES[83] = 0;
    ROOK_WHITE_VALUES[84] = 3;
    ROOK_WHITE_VALUES[85] = 3;
    ROOK_WHITE_VALUES[86] = 0;
    ROOK_WHITE_VALUES[87] = -3;
    ROOK_WHITE_VALUES[88] = -6;

    ROOK_WHITE_VALUES[91] = -6;
    ROOK_WHITE_VALUES[92] = -3;
    ROOK_WHITE_VALUES[93] = 0;
    ROOK_WHITE_VALUES[94] = 3;
    ROOK_WHITE_VALUES[95] = 3;
    ROOK_WHITE_VALUES[96] = 0;
    ROOK_WHITE_VALUES[97] = -3;
    ROOK_WHITE_VALUES[98] = -6;
    
    int counter = 119;
    for (int i = 0; i < ROOK_WHITE_VALUES.length; i++) {
      ROOK_BLACK_VALUES[counter] = ROOK_WHITE_VALUES[i];
      counter --;
    }
    
  }

  public static void initKingBoards() {

    KING_WHITE_VALUES = new int[120];
    KING_BLACK_VALUES = new int[120];

    KING_WHITE_VALUES[21] = 10;
    KING_WHITE_VALUES[22] = 20;
    KING_WHITE_VALUES[23] = 10;
    KING_WHITE_VALUES[24] = 0;
    KING_WHITE_VALUES[25] = 0;
    KING_WHITE_VALUES[26] = 0;
    KING_WHITE_VALUES[27] = 20;
    KING_WHITE_VALUES[28] = 10;


    KING_WHITE_VALUES[31] = 10;
    KING_WHITE_VALUES[32] = 15;
    KING_WHITE_VALUES[33] = 0;
    KING_WHITE_VALUES[34] = 0;
    KING_WHITE_VALUES[35] = 0;
    KING_WHITE_VALUES[36] = 0;
    KING_WHITE_VALUES[37] = 15;
    KING_WHITE_VALUES[38] = 10;

    KING_WHITE_VALUES[41] = -10;
    KING_WHITE_VALUES[42] = -20;
    KING_WHITE_VALUES[43] = -20;
    KING_WHITE_VALUES[44] = -25;
    KING_WHITE_VALUES[45] = -25;
    KING_WHITE_VALUES[46] = -20;
    KING_WHITE_VALUES[47] = -20;
    KING_WHITE_VALUES[48] = -10;

    KING_WHITE_VALUES[51] = -15;
    KING_WHITE_VALUES[52] = -25;
    KING_WHITE_VALUES[53] = -40;
    KING_WHITE_VALUES[54] = -40;
    KING_WHITE_VALUES[55] = -40;
    KING_WHITE_VALUES[56] = -40;
    KING_WHITE_VALUES[57] = -25;
    KING_WHITE_VALUES[58] = -15;

    KING_WHITE_VALUES[61] = -30;
    KING_WHITE_VALUES[62] = -40;
    KING_WHITE_VALUES[63] = -40;
    KING_WHITE_VALUES[64] = -40;
    KING_WHITE_VALUES[65] = -40;
    KING_WHITE_VALUES[66] = -40;
    KING_WHITE_VALUES[67] = -40;
    KING_WHITE_VALUES[68] = -30;

    KING_WHITE_VALUES[71] = -50;
    KING_WHITE_VALUES[72] = -50;
    KING_WHITE_VALUES[73] = -50;
    KING_WHITE_VALUES[74] = -50;
    KING_WHITE_VALUES[75] = -50;
    KING_WHITE_VALUES[76] = -50;
    KING_WHITE_VALUES[77] = -50;
    KING_WHITE_VALUES[78] = -50;

    KING_WHITE_VALUES[81] = -50;
    KING_WHITE_VALUES[82] = -50;
    KING_WHITE_VALUES[83] = -50;
    KING_WHITE_VALUES[84] = -50;
    KING_WHITE_VALUES[85] = -50;
    KING_WHITE_VALUES[86] = -50;
    KING_WHITE_VALUES[87] = -50;
    KING_WHITE_VALUES[88] = -50;

    KING_WHITE_VALUES[91] = -50;
    KING_WHITE_VALUES[92] = -50;
    KING_WHITE_VALUES[93] = -50;
    KING_WHITE_VALUES[94] = -50;
    KING_WHITE_VALUES[95] = -50;
    KING_WHITE_VALUES[96] = -50;
    KING_WHITE_VALUES[97] = -50;
    KING_WHITE_VALUES[98] = -50;

    int counter = 119;
    for (int i = 0; i < KING_WHITE_VALUES.length; i++) {
      KING_BLACK_VALUES[counter] = KING_WHITE_VALUES[i];
      counter --;
    }
    
    // Castling
    KING_BLACK_VALUES[91] = 10;
    KING_BLACK_VALUES[92] = 20;
    KING_BLACK_VALUES[93] = 10;
    KING_BLACK_VALUES[94] = 0;
    KING_BLACK_VALUES[95] = 0;
    KING_BLACK_VALUES[96] = 0;
    KING_BLACK_VALUES[97] = 20;
    KING_BLACK_VALUES[98] = 10;


  }

  
  
}
